#ifndef __AF_AUDIO_RECORDER_HXX__
#define __AF_AUDIO_RECORDER_HXX__

/**
 * to invalidate the winsock.h in windows.h file
 */
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <mmsystem.h>

#include "mymutex.hxx"
#include "audiorecorder.hxx"

class FileLog;

class EXPORT WFAudioRecorder	:	public AudioRecorder
{
public:
	// \brief Constructor
	WFAudioRecorder();

	// \brief Constructor with basic config
	WFAudioRecorder(tUInt32 bits_sample,tUInt32 sample_sec,tUInt32 block_nb,tUInt32 block_size,
		tUInt32 channel_nb,tUInt32 callback_threadproc_id=0,FileLog* filelog = NULL);

	virtual ~WFAudioRecorder();

	void Shutdown();

	virtual tInt32 Init();
	virtual tInt32 UnInit();

	void SetCallBackThreadId(tUInt32 threadid);

	
protected:
	friend class RecordHandler;
	tByte* AllocateBlocks(tUInt32 count, tUInt32 size);

	void FreeBlocks(void);

	virtual void Execute(Thread::Arg arg);

private:

	WAVEHDR* _blocks;
	HWAVEIN _device;
	//WAVEFORMATEX _format;
	BOOL _shutdown_requested;

	/* When a block of record is done, an notification event 
	 * is sent to the thread idenfitied by this thread ID */
	tUInt32 _callback_thread_id;
};

#endif // __AF_AUDIO_RECORDER_HXX__